home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / lib / addr / ap_t2s.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  1.4 KB  |  57 lines

  1. #include "util.h"               /* from ../utildir */
  2. #include "conf.h"               /* from ../mmdf/h */
  3. #include "ch.h"
  4. #include "ap.h"
  5. #include "dm.h"
  6. #include "ll_log.h"
  7.  
  8. /*  Format one address from parse tree, into a string
  9.  *
  10.  *  Returns:    pointer to next node, after address
  11.  *               0 if end of tree
  12.  *              NOTOK if error
  13.  */
  14.  
  15. extern LLog *logptr;
  16. extern char *strdup();
  17. extern char *ap_p2s();
  18. extern AP_ptr ap_t2parts();
  19.  
  20. AP_ptr
  21.     ap_t2s (thetree, strpp)
  22.     AP_ptr thetree;             /* the parse tree */
  23.     char **strpp;               /* where to stuff the string */
  24. {
  25.     AP_ptr locptr,              /* in case we need to fake personal name */
  26.        grpptr,
  27.        namptr,
  28.        domptr,
  29.        routptr,
  30.        rtntree;
  31.  
  32. #ifdef DEBUG
  33.     ll_log (logptr, LLOGFTR, "ap_t2s ()");
  34. #endif
  35.  
  36.     rtntree = ap_t2parts (thetree, &grpptr, &namptr,
  37.               &locptr, &domptr, &routptr);
  38.     if (rtntree == (AP_ptr)NOTOK) {
  39.     ll_log (logptr, LLOGTMP, "ap_t2s: error from ap_t2parts()");
  40.     *strpp = strdup ("(MMDF Error!)");
  41.     return ((AP_ptr)NOTOK);
  42.     }
  43.  
  44.     *strpp = ap_p2s (grpptr, namptr, locptr, domptr, routptr);
  45.  
  46.     if(*strpp == (char *)MAYBE){
  47.     *strpp = strdup("");        /* is this needed ?? */
  48.     return ((AP_ptr)MAYBE);
  49.     }
  50.     else if (*strpp == (char *)NOTOK) {
  51.     ll_log (logptr, LLOGTMP, "ap_t2s: error from ap_p2s()");
  52.     *strpp = strdup ("(MMDF Error!)");
  53.     return ((AP_ptr)NOTOK);
  54.     }
  55.     return (rtntree);
  56. }
  57.